package com.songlanyun.modules.signin.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.songlanyun.common.utils.R;
import com.songlanyun.modules.signin.model.dto.SingInConfigDTO;
import com.songlanyun.modules.signin.service.SignInConfigService;
import com.songlanyun.modules.user.controller.AbstractController;

// import org.apache.shiro.authz.annotation.RequiresPermissions;

/**
 * 签到管理-签到配置
 *
 * @author lijiahe
 * @date 2022-08-03
 */
@RestController
@RequestMapping("admin/signInConfig")
public class SignInConfigController extends AbstractController {
    @Autowired
    private SignInConfigService signInConfigService;

    @GetMapping("/info")
    // @RequiresPermissions("signIn:config:info")
    public R info() {
        return R.ok().put("data", signInConfigService.get(false));
    }

    @PostMapping("/addOrEdit")
    // @RequiresPermissions("signIn:config:save")
    public R addOrEdit(@RequestBody SingInConfigDTO dto) {
        Long userId = getUserId();
        dto.setCreateBy(userId);
        dto.setUpdateBy(userId);
        signInConfigService.addOrEdit(dto);
        return R.ok();
    }

}
